module Fabriq
  module Skype
    class Room

      attr_accessor :adapter, :id, :topic, :members, :raw

      def initialize(adapter, id, members, raw)
        @adapter = adapter
        @id = id
        @members = members
        @raw = raw
      end

      def private_session?
        @members.count == 2
      end

      def send_message(body, opts = {})
        message = build_message_from_string(body, opts)
        @adapter.enqueue_outgoing_message(message)
      end

      def build_message_from_string(body, opts = {})
        body = "@%s: %s" % [opts[:to], body] if opts[:to] && !private_session?
        Fabriq::Skype::Message.new(self, body)
      end

    end
  end
end